import java.util.*;
public class main1 {
    public int findMaxGap(int[] A, int n) {
// write code here
        int mx = A[0];
        for(int i = 1; i < n; ++i)
            mx = Math.max(mx, A[i]);
        return mx - Math.min(A[0], A[n - 1]);
    }
}



